<template>
  <div>
    <el-form :model="question" label-width="120px">
      <el-form-item label="问题">
        <el-input v-model="question.title" />
      </el-form-item>
      <el-form-item label="问题类型">
        <el-select v-model="question.type" disabled>
          <el-option label="技术点" value="技术点" />
          <el-option label="项目" value="项目" />
          <el-option label="生活" value="生活" />
          <el-option label="感情" value="感情" />
        </el-select>
      </el-form-item>
      <el-form-item label="问题描述">
        <el-input v-model="question.info" type="textarea" />
      </el-form-item>
      <el-form-item label="参考答案">
        <el-input v-model="question.answer" type="textarea" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="update">修改问题</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup>
import {ref,onMounted} from 'vue'
import axios from "axios";
import {useRouter} from 'vue-router'
import {useStore} from "vuex";

const store = useStore()
const router = useRouter();
const question=ref({})

onMounted(()=>{
  question.value=store.state.q;
})
const update=()=>{
  //请求接口  Axios post json 语法格式
  axios.post("question/update",question.value).then(res=>{
    if(res.data.code==0){
      router.push("/list");
    }else{
      alert("亲，修改问题失败！")
    }
  })
}
</script>

<style scoped>

</style>
